package com.jj.service.impl;

import com.jj.entity.Dormitory;
import com.jj.mapper.DormitoryMapper;
import com.jj.service.DormitoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional(readOnly = true)
public class DormitoryServiceImpl implements DormitoryService {
    @Autowired
    private DormitoryMapper dormitoryMapper;
    @Override
    public List<Dormitory> selectAllDormitory() {
        return dormitoryMapper.selectAllDormitory();
    }

    @Override
    public Dormitory selectAllByIdDormitory(Long id) {
        return dormitoryMapper.selectAllByIdDormitory(id);
    }

    @Override
    @Transactional
    public boolean addDormitory(Dormitory dormitory) {
        return dormitoryMapper.addDormitory(dormitory)>0 ? true : false;
    }

    @Override
    @Transactional
    public boolean updateDormitory(Dormitory dormitory) {
        return dormitoryMapper.updateDormitory(dormitory)>0 ? true : false;
    }

    @Override
    @Transactional
    public boolean deleteDormitory(Long id) {
        return dormitoryMapper.deleteDormitory(id)>0 ? true : false;
    }
}
